package yqt.com.cnki.dao.impl;

import cnki.tpi.kbatis.sqlsession.SqlSession;
import cnki.tpi.kbatis.utils.DataSourceUtil;
import org.springframework.stereotype.Repository;
import yqt.com.cnki.bo.QBZXBo;
import yqt.com.cnki.dao.IQBZXDao;
import yqt.com.cnki.po.KeyValuePo;
import yqt.com.cnki.po.QBZXPo;

import java.util.List;

/**
 * Description:
 *
 * @author BaiGe
 * @date: 2021/11/10 15:16
 * @Version 1.0
 */
@Repository
public class QBZXDaoImpl implements IQBZXDao {
    @Override
    public QBZXPo getQBZXById(Integer sysID) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQBZXDao.getQBZXById";
        return sqlSession.selectOne(statementId, sysID, false);
    }

    @Override
    public List<KeyValuePo> getSortNameFromDB() {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQBZXDao.getSortNameFromDB";
        return sqlSession.selectList(statementId, null, false);
    }

    @Override
    public List<QBZXPo> getQBZXBySortName_LimitFive(QBZXBo qbzxBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQBZXDao.getQBZXBySortName_LimitFive";
        return sqlSession.selectList(statementId, qbzxBo, false);
    }

    @Override
    public List<QBZXPo> getQBZXBySortName_List(QBZXBo qbzxBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQBZXDao.getQBZXBySortName_List";
        return sqlSession.selectList(statementId, qbzxBo, false);
    }

    @Override
    public long getQBZXBySortName_Count(QBZXBo qbzxBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQBZXDao.getQBZXBySortName_Count";
        return sqlSession.getCount(statementId, qbzxBo);
    }

    @Override
    public List<QBZXPo> getCover(String source) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IQBZXDao.getCover";
        return sqlSession.selectList(statementId, source, false);
    }
}
